function ZOYOE_UI(env,yui,config){
  var YUI = yui;
  var ENV = env; 
  var UI = this;
  /* UI Component */
  this.right_dock = null;
  this.left_dock = null;
  this.content = null; 
  this.top_dock = null;
  this.bot_dock = null;
  this.hibernate_count = 0;
  this.content_active = true;
  this.submit_cb = null;
  this.refresh = false;
  this.replydata = null;
  this.update = null;
  this.complete = null;
  this.dialog_title = null;
  this.dialog_name = null;
  this.statis_dialog = false;
  this.static_panel = false;
  var dialog_html = "<div id='dialog' >";
  dialog_html += "<div class='dialog shadow'>";
  if(config && config.static_dialog){
  }else{
    // dialog_html += "<img src='/res/close.png' style='position:absolute;right:-15px;cursor:pointer;width:30px;height:30px;top:-15px;' onclick='zoyoe.ui.HideDialog()'></img>"
    dialog_html += "<img src='/res/close.png' style='position:absolute;right:15px;cursor:pointer;top:15px;z-index:200;' onclick='zoyoe.ui.HideDialog()'></img>"
  }
  dialog_html += ("<div class='dialog-hint'><a></a><h5></h5>"
  + "</div>"
  + "<div class='dialog-left'>"
  +  "<div class='dialog-content'></div>"
  +  "</div>"
  +  "<div class='dialog-middle'></div>"
  +  "<div class='dialog-right'>"
  +  "</div>"
  +  "</div></div>");
  this.dialog = YUI.Node.create(dialog_html);
  if(config && config.static_dialog){
    this.static_dialog = true;
  }else{
    this.dialog.set('className','on-msk');
  }
  if(config && config.static_panel){
    this.static_panel = true;
  }else{
    var panel = document.getElementById('panel');
    if(panel){panel.className = "on-msk";}
  }
  if(config && config.selector){
    YUI.one(config.selector).append(this.dialog);
  }else{
    YUI.one("body").append(this.dialog);
  }
  this.panel_name = null;
  this.panel = YUI.one("#panel")

  this.Resize = function(){
    var img_whole_divs = YUI.all('div.img-whole'); 
    img_whole_divs.each(function(div){
      var dom_ele = YUI.Node.getDOMNode(div);
      var img_ele = YUI.Node.getDOMNode(div.one('img'));
      div.one('img').setStyle('max-height',dom_ele.offsetHeight+'px');
      div.one('img').setStyle('max-height',dom_ele.offsetHeight+'px');
      img_ele.style.top = ((dom_ele.offsetHeight - img_ele.offsetHeight)/2) + 'px';
    });
  }

  YUI.on('windowresize',function(e){UI.Resize();});

  function DialogStyleCommit(){
  }

  function DialogStyleAlert(){
  }

  function DialogStyleSucc(){
  }

  /* Set the complete function */
 function StartIO(uri,config,call_back,paras){
    var sub = YUI.on('io:complete',function(id,o,args){
      call_back(id,o,args);
      sub.detach();
    },YUI,paras);
    var request = YUI.io(uri,config);
  }
  function BuildGeneralMsg(msg,url,error_hint){
    var title = YUI.one('#dialog .dialog-hint h2');
    var hint = YUI.one('#dialog .dialog-hint a');
    var dialog = YUI.one('#dialog .dialog-content');
    if(error_hint){
      hint.set('innerHTML',"<img src = '/res/alert-icon.png'/>" + error_hint);

    }
    dialog.set('innerHTML',"<div class='msg'>"+msg+"</div>");
    UI.submit_cb = null;
  }
  function BuildResponseMsg(msg,url,error_hint){
    var title = YUI.one('#dialog .dialog-hint h2');
    var hint = YUI.one('#dialog .dialog-hint a');
    var dialog = YUI.one('#dialog .dialog-content');
    if(error_hint){
      hint.set('innerHTML',"<img src = '/res/alert-icon.png'/>" + error_hint);

    }
    msg += "<p><span class='commit' onclick='zoyoe.ui.HideDialog();'>"
        + "Ok</span><br style='clear:both'/></p>"; 
    dialog.set('innerHTML',"<div class='msg'>"+msg+"</div>");
    UI.submit_cb = null;
  }

  // c
  function BuildSuccMsg(msg, serviceName){
    var title = YUI.one('#dialog .dialog-hint h2');
    var hint = YUI.one('#dialog .dialog-hint a');
    var dialog = YUI.one('#dialog .dialog-content');
    // msg = "<p>"+msg+"</p>";
    msg_changed=msg.replace(/[\r\n]/g, "");
    msg_changed=msg_changed.replace(/[ ]/g, "");
    // alert("msg_changed is ["+msg_changed+"]");

    var changePWflag=null;
    if(msg_changed=='PasswordChangedSuccessfully')
	changePWflag="passwordreset";

    msg = "<div class='msg'>" + msg + "</div>";

    // alert(serviceName);
    if (changePWflag=="passwordreset"){
	msg += "<p><span class='commit' onclick=\""+"location.href='/Search/'"+"\">"
        + "Continue</span><br style='clear:both'/></p>";
    }else {    
      if (serviceName == null) {
        // alert("re location is here ");
        msg += "<p><span class='commit' onclick='zoyoe.ui.SubmitForm();location.reload();'>"
          + "Continue</span><br style='clear:both'/></p>";
      }else{
        //remove the return from the serviceName
        length = serviceName.length;
        serviceName = serviceName.substring(0,length-3);

        msg += "<p><span class='commit' onclick='zoyoe.ui.SubmitForm()'>"   //remove:;zoyoe.ui.gotoService(" + serviceName + ");
          + "Continue</span><br style='clear:both'/></p>";
      }
    }

    dialog.set('innerHTML',msg);
    hint.set('innerHTML',"");
    UI.submit_cb = null;
  }
  
  function BuildErrorMsg(msg,url){
    var hint = YUI.one('#dialog .dialog-hint a');
    var url = url;
    if(url == null){
      url = "";
    }
    hint.set('innerHTML',"<img src = '/res/alert-icon.png'/>" + msg);
  }
  function ClearHint(){
    var hint = YUI.one('#dialog .dialog-hint a');
    hint.set('innerHTML',"");
  }

  this.BuildGeneralMsg = BuildGeneralMsg;
  this.BuildSuccMsg = BuildSuccMsg;
  this.BuildErrorMsg = BuildErrorMsg;
  this.BuildResponseMsg = BuildResponseMsg;
  this.HideDialog = function(){
    var dialog = YUI.one('#dialog .dialog-content');
    var hint = YUI.one('#dialog .dialog-hint');
    if(UI.static_dialog != true){
      hint.set('innerHTML',"<a></a><h2></h2>");
      YUI.one('#dialog').setStyle('display','none');
      this.ActivateContent();
    }
  }
  this.closeWindow = function(){ 
    window.location = "http://www.google.com.au/";
  }
  this.gotoService = function(serviceName){ 
    window.location = "/core/service/" + serviceName + "/";
  }
  this.ShowDialog = function(title,loading){
    if(UI.static_dialog != true){
      this.HibernateContent();
      YUI.one('#dialog').setStyle('display','block');
    }
    var hint = YUI.one('#dialog .dialog-hint');
    var ghint = "<a></a><h2>" + title + "</h2>";
    UI.dialog_title = title;
    hint.set('innerHTML',ghint);
    if(loading){
      var dialog = YUI.one('#dialog .dialog-hint a');
      dialog.set('innerHTML',"loading ...");
    }
    dialog_right = YUI.one('#dialog .dialog-right');
    dialog_right.append("<iframe frameborder='0' class='wiki-frame' style='border:none'></iframe>");
  }
  /* Alert Dialog, Ask you to confirm your action */
  this.GeneralAlert = function(msg,hint,call_back,refresh){
    this.ShowDialog('Alert',false)
    msg = "<div class='lane'>"+msg+"</div>";
    msg += "<p>" 
        + "<span class='commit' onclick='zoyoe.ui.SubmitForm();'>Continue</span>"
        + "<span class='cancel' onclick='zoyoe.ui.HideDialog();'>Cancel</span>"
        + "<br style='clear:both'/></p>"; 
    DialogStyleAlert();
    var dialog = YUI.one('#dialog .dialog-content');
    dialog.set('innerHTML',msg);
    this.submit_cb = call_back;
    this.refresh = refresh;
  }
  /* ResopnseDialog which is not triggered by a info_collect dialog*/
  this.ResponseDialog = function(uri,config,refresh,info){
    /* uri: the request uri you will post or get
       config: the yui io config 
       refresh: whether refresh the page(whole or partially)
       info: information about how to refresh the page
    */
    this.ShowDialog('Response',true);
    DialogStyleSucc();
    function complete(id,o,args){
      ClearHint();
      env.ALERT(o.responseText);
      var data = o.responseXML;
      if(data && data.documentElement){
        if(data.documentElement.tagName == 'SUCC'){
          var msg = data.documentElement.getElementsByTagName('HTMLMSG')[0].firstChild.data;
          UI.BuildSuccMsg(msg,null);
          UI.refresh = true;
          UI.update = info;
        }else{ /* An Error has occurred */
          var msg = data.documentElement.getElementsByTagName('HTMLMSG')[0].firstChild.data;
          var errors = data.documentElement.getElementsByTagName('ERROR');
          if(errors.length > 0 ){
            var fst_error = errors[0].firstChild.data;
            UI.BuildResponseMsg(msg,null,fst_error);
          }else{
            UI.BuildResponseMsg(msg);
          }
        }
      }else{
         UI.BuildGeneralMsg(o.responseText);
      }
    }
    StartIO(uri,config,complete);
  }
  /* This is used eto handle the result of a info_colloect dialog */
  this.GeneralDialogCont = function(uri,config,refresh,info){
    this.ShowDialog(UI.dialog_title,true);
    function complete(id,o,args){
      ClearHint();
      var data = o.responseXML;
      ENV.ALERT(o.responseText);
      if(data){
        if(data.documentElement.tagName == 'SUCC'){
         var msg = data.documentElement.getElementsByTagName('HTMLMSG')[0].firstChild.data;


         var nodelist = o.responseXML.getElementsByTagName('key');
         var serviceName;
         for (var i = 0; i < nodelist.length; i++) {
           var node = nodelist[i];
           if (node.getAttribute('name') == 'name') {
             serviceName = node.childNodes[0].nodeValue;
           }
         }

         BuildSuccMsg(msg,serviceName);
         UI.refresh = refresh;
         UI.replydata = data;
         UI.update = info;
         DialogStyleSucc();
        }else{
          var errors = data.documentElement.getElementsByTagName('ERROR');
          if(errors.length > 0 ){
            var fst_error = errors[0].firstChild.data;
            ENV.ALERT(fst_error);
            UI.BuildErrorMsg(fst_error);
          }
          else{
            UI.BuildErrorMsg('UNKOW ERROR!!');
          }
          var error_nodes = YUI.all('#' + UI.dialog_name + ' .input-error');
          var path = "#" + UI.dialog_name + " label";
          var labels = YUI.all(path);
          for (var i=0;i<errors.length;i++){
            var name = errors[i].getAttribute('name');
            for(var j=0;j<labels.size();j++){
              var anode = labels.item(j);
              var anode_ele = YUI.Node.getDOMNode(anode);
              if(anode_ele.htmlFor == name){

                  anode.one('span').replaceClass('input-fine','input-error');

              }
            }
          }
        }
      }else{
         var msg = o.responseText;
         UI.BuildGeneralMsg(msg);
      }
    }
    StartIO(uri,config,complete);
  }
  this.InfoCollectDialog = function(h,uri,dialog_name,submit_callback,init_callback,wiki){
    DialogStyleCommit();
    this.ShowDialog(h,true);
    this.submit_cb = submit_callback;
    this.dialog_name = dialog_name;
    function complete(io,o,args){
      ClearHint();
      var msg = o.responseText+" ";
      var d = YUI.one('#dialog .dialog-content');
      var dialog_ele = YUI.Node.getDOMNode(d);
      dialog_ele.innerHTML = msg;

      var dmiddle = YUI.one('#dialog .dialog-middle');
      var dmiddle_ele = YUI.Node.getDOMNode(dmiddle);
      dmiddle_ele.style.border = "1px solid gray";

      if(ENV.ElementExtension){
        ENV.ElementExtension.BuildExtensionElements(d);
      }
      if(init_callback){
        init_callback(YUI.one("#dialog"));
      }
      DialogStyleCommit();
    } 
    StartIO(uri,config,complete);
    if(wiki){
      this.ShowWiki(wiki);
    }
  }
  this.ShowWiki = function(wiki){
    YUI.one('#dialog .wiki-frame').set('src',wiki);
  }

/*  start */
  this.InfoCollectWarningDialog = function(h,uri,dialog_name,submit_callback,init_callback,wiki){
    //DialogStyleCommit();
    this.ShowDialog(h,false);
    this.submit_cb = submit_callback;
    this.dialog_name = dialog_name;
    function complete(io,o,args){
      ClearHint();
      //var msg = o.responseText+" ";

      var dhint = YUI.one('#dialog .dialog-hint');
      var dhint_ele = YUI.Node.getDOMNode(dhint);
      //dhint_ele.style.height = "500px";
      dhint.set('innerHTML',"<div style='position:relative;top:50px;text-align:center'>"
+"<h1 style='color:red'>Largest adults service search engine</h1>"
+"</br><p>Please note that this site contains sexually oriented adult material</br>"
+"</br>intended for individuals 18 years of age or older and of legal age to view</br>"
+"</br>sexually explicit material as determined by the local and national laws of</br>"
+"</br>the region in which you reside. If you are under 18 you cannot Legally</br>"
+"</br>Enter this Site. Please Leave this site.<p>"

+"</br><div onclick='zoyoe.ui.closeWindow()' style='z-index:200;color:red;font-size:30px;cursor:pointer'>Leave</div>"
+"</br><div onclick='zoyoe.ui.HideDialog()' style='z-index:200;color:red;font-size:30px;cursor:pointer'>Enter</div>"
//+"</br><img src='/res/leave.png' style='cursor:pointer;z-index:200;' onclick='zoyoe.ui.closeWindow()'></img>"
//+"<img src='/res/enter.png' style='cursor:pointer;z-index:200;' onclick='zoyoe.ui.HideDialog()'></img>"
+"</div>"
       );


      //if(ENV.ElementExtension){
      //  ENV.ElementExtension.BuildExtensionElements(d);
      //}
      //if(init_callback){
      //  init_callback(YUI.one("#dialog"));
      //}
      //DialogStyleCommit();
    } 
    StartIO(uri,config,complete);

  }

/* end */
  this.IframeDialog = function(h,uri,dialog_name,submit_callback){
    this.ShowDialog(h,false);
    this.submit_cb = submit_callback;
    this.dialog_name = dialog_name;
    var dialog = YUI.one('#dialog .dialog-content');
    var ht = "<iframe frameborder='0' id='"+dialog_name + "' src = '"+uri+"'></iframe>"
    dialog.set('innerHTML',ht);
  }
  this.HibernateContent = function(no_opacity){
    /* We will not check the existance of the mask, 
    since we can not handle the problem once the convention is not applied */
    this.hibernate_count += 1;
    if(this.hibernate_count == 1){
      var mask = document.getElementById('zsk');
      if (mask != null) {
        if(no_opacity){
          mask.className = 'msk_nop';
        }else{
          mask.className = 'msk';
        }
        mask.style.display = 'block';
      }
      this.content_active = false;
      document.body.style.overflow = "hidden";
    }
  }
  this.ActivateContent = function(){
    this.hibernate_count -= 1;
    if(this.hibernate_count < 0){
      //alert("fail");
    }
    if(this.hibernate_count == 0){
      var mask = document.getElementById('zsk');
      if (mask != null) {
        mask.style.display = 'none';
      }
      document.body.style.overflow = "";
      this.content_active = true;
    }
  }

  this.InputKeydownListener = function(event) {
      switch(event.keyCode) {
      case 13: 
        UI.SubmitForm();
        break;
      case 27:
        UI.HideDialog();
        break;
      default:
        break;
      }
  }
  function LoadContent(content,uri){
    function complete(id,o,args){
      var data = o.responseText;
      ENV.ALERT(o.responseText);
      content.one('div.panel-content').set("innerHTML",data);
    }
    var config = {
      method: 'get'
    };
    StartIO(uri,config,complete);
  }
  this.PanelLeft = function(){
    return YUI.one('#panel .panel-left');
  }
  this.DialogContent = function(){
    return YUI.one('#dialog .dialog-content');
  }
  this.DialogRight = function(){
    return YUI.onen('#dialog .dialog-content');
  }
  this.LoadFrameForm = function(uri){
    function complete(id,o,args){
      var data = o.responseText;
      ENV.ALERT(o.responseText);
      var left = YUI.one('#panel .panel-left');
      left.set("innerHTML",data);
      var icons = left.all('input.iconpath');

      icons.each(function(container){
        container.on('focus',function(e){
        var info_uri = "/gallery/info/"+ENV.service_name+"/?";
        var dialog_right = YUI.one("#dialog .dialog-right");
        UI.ShowDialog('Select Icon',true);
        /*dialog_right.set('innerHTML',"<div class='right-content'" 
            + "style='border:1px solid #EAEAEA;position:absolute;"
            + "left:0px;top:0px;bottom:0px;right:10px;background-color:whiteSmoke'></div>");*/
        dialog_right.set('innerHTML',"<div class='right-content'></div>");
        function info_complete(io,o,args){
          ClearHint();
          var current = null; 
          var current_ele = null;
          var gs = o.responseXML.getElementsByTagName('G');
          var left = YUI.one('#dialog .dialog-content');
          left.set('innerHTML',"<p style='margin:0px 15px 15px 15px;'>Gallery List</p>");
          var glist = YUI.Node.create("<ul class='gallery-list'></ul>");
          for (var i=0;i<gs.length;i++){
            var item = YUI.Node.create("<li>" + gs[i].getAttribute('name') + "</li>");
            if(i==0){
              item.addClass('current');
            }
            glist.append(item);
            function icon_cb(img,gname,imgname){
              return function(){
                if(current_ele){
                  current_ele.removeClass('current');
                }
                img.addClass('current');
                current = gname + "/" + imgname;
                current_ele = img;
              }
            }
            function cb(gallery,item){
              return function(){
                var right = YUI.one('#dialog .right-content');
                var imgs = gallery.getElementsByTagName('IMG');
                var gname = gallery.getAttribute('name');
                right.set('innerHTML','');
                for(var j= 0;j<imgs.length;j++){
                  var imgname = imgs[j].getAttribute('name');
                  var src = "/gallery/image/"+ENV.service_name +"/" + gname + "/" + imgname + "/?sc=true";
                  var img = YUI.Node.create("<img src='" + src +  "'></img>");
                  right.append(img);
                  img.on('click',icon_cb(img,gname,imgname));
                  //img.on('click',function(){alert('abc');});
                }
                YUI.all('#dialog .gallery-list li').removeClass('current');
                item.addClass('current');
              }
            };
            item.on('click',cb(gs[i],item));
          }
          left.append(glist);
          var btnlane = YUI.Node.create("<p></p>");
          var commitbtn = YUI.Node.create("<span class='commit'>Select</span>");
          var cancelbtn = YUI.Node.create("<span class='cancel' onclick='zoyoe.ui.HideDialog();'>back</span>");
          commitbtn.on('click',function(){
            if(current == null){
              UI.BuildErrorMsg('Please select an icon');
            }else{
              container.set('value',ENV.service_name + '/' + current);
              UI.HideDialog();
            }
          });
          btnlane.append(commitbtn);
          btnlane.append(cancelbtn);
          left.append(btnlane);
          left.append("<br style='clear:both'></br>");
          if(gs.length > 0){
            var right = YUI.one('#dialog .right-content');
            var imgs = gs[0].getElementsByTagName('IMG');
            var gname = gs[0].getAttribute('name');
            for(var j= 0;j<imgs.length;j++){
              var imgname = imgs[j].getAttribute('name');
              var src = "/gallery/image/"+ENV.service_name +"/" + gname + "/" + imgname + "/?sc=true";
              var img = YUI.Node.create("<img src='" + src +  "'></img>");
              img.on('click',icon_cb(img,gname,imgname));
              right.append(img);
            }
          }
        }
        var config = {
          method: 'get'
        }
        StartIO(info_uri,config,info_complete);
      });});
    }
    var config = {
      method: 'get'
    }
    StartIO(uri,config,complete);
  }
  this.ClearButtons = function(){
    var btn_lane = YUI.one('#panel .button-lane');
    btn_lane.set("innerHTML","");
  }
  this.LoadButton = function(str,callback){
    var btn_lane = YUI.one('#panel .button-lane');
    ele = YUI.Node.create("<div class='spangray'>"+ str + "</div>"); 
    ele.on('click',callback);
    btn_lane.append(ele);
  }
  this.UpdateUI = function(cb){
    if(UI.update){
      if(UI.update.comp_id){
        var config = {
          method: 'get'
        }
        var p = YUI.one("#"+UI.update.comp_id).get('parentNode');
        p.set('innerHTML','loading');
        function complete(id,o,args){
          zoyoe.ALERT(o.responseText);
          p.set('innerHTML',o.responseText);
          UI.update = null;
          if(cb){cb();}
          if(zoyoe.ElementExtension){
            zoyoe.ElementExtension.BuildExtensionElements(p);
          }
        }
        StartIO(UI.update.uri,config,complete);
      }else if(UI.update.uri){
        ENV.Redirect(UI.update.uri);
      }else if(typeof(UI.update) == "function"){
        UI.update(UI.replydata);
      }
    }else{
      location.reload(true); 
    }
  }
  function BuildPanelHint(title){
    var ghint = "";
    if(!UI.static_panel){
      // var ghint = "<a class='gbutton' onclick='zoyoe.ui.HidePanel()'>&#9746</a>"
      var ghint = "<img src='/res/close.png' style='position:absolute;right:15px;cursor:pointer;top:15px;z-index:200;' onclick='zoyoe.ui.HidePanel()'></img>"
    }
    ghint += title;
    return ghint;
  }
  this.SubmitForm = function(){
    var form_obj = document.getElementById(UI.dialog_name);
    if(form_obj!=null){
      if(UI.submit_cb){
        UI.HideDialog();
        UI.submit_cb(form_obj);
      }else{
        UI.HideDialog();
      } 
    }else{
      if(UI.submit_cb){
        UI.HideDialog();
        UI.submit_cb();
      }else{
        if(UI.refresh){
          UI.UpdateUI(function(){ // Normal Update
            UI.HideDialog();
          });
        }else{
          UI.HideDialog();
        }
      }
    }
  }
  this.ShowPanel = function(panel_name,args,update_info,cb){
  /* Currently only two kinds of panel is supported
   * 1. Gallery Panel (Resource Panel)
   * 2. Data Panel
   */
  
  /* First Of All, Hibernate the content */
  if(UI.static_panel != true){
    this.HibernateContent();
  }
  UI.update = update_info; 

  /* Prepare the content */
  var panel = YUI.one('#panel .panel-content');
  var hint = YUI.one('#panel .panel-hint');
  var btnlane = YUI.one('#panel .button-lane');
  var pleft = YUI.one('#panel .panel-left');

  /* Clear The Content */
  btnlane.set("innerHTML","");
  pleft.set("innerHTML","");
  panel.set("innerHTML","");
  if(panel_name == "gallery"){
    gnames = args;
    var icons_html = "";
    var tstamp = "";
    if(ENV){
      tstamp = "&tstamp="+ENV.TimeStamp();
    }
    /* The Uri Where We Get The Photo Data */
    var info_uri = "/gallery/info/"+ENV.service_name+"/?" + tstamp;
    function complete(io,o,args){
      var icon_containers = UI.panel.all(' .gicon')
      var gs = o.responseXML.getElementsByTagName('G');
      var g = null;
      var gname = args[0];
//      for(var i=0;i<args.length;i++){
        for (var i=0;i<gs.length;i++){
          if(gname && gs[i].getAttribute('name') == gname){
            g = gs[i];
          }
        }
        if(g == null){
          if(gs.length == 0){
            return;
          }else{
             g = gs[0];
          }
        }
        var urls = g.getElementsByTagName('IMG'); 
        var gname = g.getAttribute('name');
        var prefix = "/gallery/image/"+ENV.service_name+"/"+gname;
        var idx = 0;
        var name_list = [];
        //05/09/2012 store name for banner(left and right)
	var banner_tag= Array("left banner", "right banner");
        var banner_count=0;
        //05/09/2012
        var icons_html = "<form>";
        for(;idx<urls.length;idx++){
          var name = urls[idx].getAttribute('name');
          icons_html += "<a class='gicon'>"
            + "<img class='shadow' onclick=\"zoyoe.comps['GALLERY'].Select('"+name+"',this)\"  src='"
            + prefix + '/' + name + "/?sc=small" + tstamp + "'></img>"
            //+ "<span>last modified: 2011-12-14</span>"
            + "<span>" + gname + " - " + name + "</span>";
          if (zoyoe.has_authority) {
            icons_html += "<span><li style='z-index:2' onclick=\"zoyoe.comps['GALLERY'].Select('"+name+"',this);zoyoe.comps['GALLERY'].ModifyImg();\">modify</li>"
	     //add banner identifier 05/09/2012
             if(gname!="banner"){            
icons_html += "<li onclick=\"zoyoe.comps['GALLERY'].Select('"+name+"',this);zoyoe.comps['GALLERY'].DeleteImg('"+ gname + "','" + name +"');\">delete</li></span>";
	     }
             //add tag for banner picture 05/09/2012
             else{
               icons_html +="<p style='font-size:20px;clear:both'>"+banner_tag[banner_count]+"</p>"
               banner_count++;
             }
             //05/09/2012
             
            //+ "<li onclick=\"zoyoe.comps['GALLERY'].DeleteImg()\">delete</li></span>";
            //+ "<span><input type='checkbox' name='iname' value='" + name + "'/></span>"
          }
          icons_html += "</a>";
          name_list.push(name);
        }
	//add banner identifier 05/09/2012
        if (zoyoe.has_authority && gname!="banner") {
          icons_html += "<a onclick=\"zoyoe.comps['GALLERY'].AddImg();\" class='gicon-tools'>"
            + "<img src='/res/icons/add-btn.png'></img><span>Add Image</span></a>";
        }
        icons_html += "</form>";
        pleft.set("innerHTML",icons_html);
        zoyoe.comps['GALLERY'].ManageGallery(gname,name_list,function(innerHTML){
          panel.set('innerHTML',innerHTML);

        });
//    }/* Currently not support full gallery display */
      if(cb){
        cb();
      }
    }
    var config = {
      method: 'GET'
    }
    StartIO(info_uri,config,complete,gnames);
    var ghint_html = "<h2><a href='/core/service/" + ENV.service_name+"/'>" + ENV.service_name + "</a>";
    ghint_html += " &raquo; "
    var ghint = BuildPanelHint(ghint_html + "gallery &raquo; " + gnames[0] + "</h2>"); 
    hint.set('innerHTML',ghint);
    //add banner identifier 05/09/2012
    if (zoyoe.has_authority && gnames[0]!="banner") {
      this.LoadButton("Delete Gallery",function(){zoyoe.comps['GALLERY'].DelGallery(gnames[0]);});
    }
    //this.LoadButton("Get Code",function(){zoyoe.comps['GALLERY'].GetCode(gnames[0]);});
    YUI.one('#panel').setStyle('display','block');
  }else if(panel_name == "data"){
    this.panel_name = "data";
    var path = args.path; /* convension used here */ 
    var render_uri = "/xml/rend/"+ENV.service_name+"/"+path+"/";
    var add_uri = "/xml/add/"+ENV.service_name+"/"+path+"/";
    var ghint_html = "<h2><a href='/core/service/" + ENV.service_name+"/'>" + ENV.service_name + "</a>";
    ghint_html += " &raquo; data panel &raquo;" + path + "</h2>"
    var ghint = BuildPanelHint(ghint_html);
    hint.set('innerHTML',ghint);
    LoadContent(UI.panel,render_uri);
    YUI.one('#panel').setStyle('display','block');
    YUI.one('#panel .panel-content').setStyle('overflow-y','scroll');
  }else if(panel_name == 'map'){
    YUI.one('#panel').setStyle('display','block');
    this.LoadButton("Quick Publish",function(){zoyoe.admin.ShowAddServiceDialog()});
    var ghint = BuildPanelHint("<h2>Service Cards &raquo; Distribution:</h2>");
    hint.set('innerHTML',ghint);
    YUI.one('#panel').setStyle('display','block');
  }else if(panel_name == "fbapp"){
    var fbhtml = "<iframe src='https://www.facebook.com/dialog/oauth?client_id=360231047327032&redirect_uri=https://apps.facebook.com/zoyoeproject/'></iframe>"
    panel.set("innerHTML",fbhtml);
    YUI.one('#panel').setStyle('display','block');
  }else{
    alert("fatal error");
    UI.ActivateContent();
    return;
  }
 }
 this.PanelFormSubmit =function (uri,config,left_ref,right_ref){
  function complete(id,o,args){
    if(left_ref){
      UI.panel.one('div.panel-left').set("innerHTML",o.responseText);
    }
    if(right_ref){
      var render_uri = "/xml/rend/"+ENV.service_name+"/"+right_ref+"/";
      LoadContent(UI.panel,render_uri);
    }
  }
  StartIO(uri,config,complete);
 }
 this.HidePanel = function(){
   //UI.UpdateUI();
   if(UI.static_panel != true){
     this.ActivateContent();
     UI.panel.setStyle('display','none');
   }
 }

}



